{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# TensorFlow2.0教程-使用RNN实现文本分类"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.0.0-alpha0\n"
     ]
    }
   ],
   "source": [
    "from __future__ import absolute_import, division, print_function, unicode_literals\n",
    "import tensorflow as tf\n",
    "import tensorflow.keras as keras\n",
    "print(tf.__version__)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.使用tensorflow_datasets 构造输入数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31mspacy 2.0.18 has requirement numpy>=1.15.0, but you'll have numpy 1.14.3 which is incompatible.\u001b[0m\n",
      "\u001b[31mplotnine 0.5.1 has requirement matplotlib>=3.0.0, but you'll have matplotlib 2.2.2 which is incompatible.\u001b[0m\n",
      "\u001b[31mplotnine 0.5.1 has requirement pandas>=0.23.4, but you'll have pandas 0.23.0 which is incompatible.\u001b[0m\n",
      "\u001b[31mneo4j-driver 1.6.2 has requirement neotime==1.0.0, but you'll have neotime 1.7.2 which is incompatible.\u001b[0m\n",
      "\u001b[31mmizani 0.5.3 has requirement pandas>=0.23.4, but you'll have pandas 0.23.0 which is incompatible.\u001b[0m\n",
      "\u001b[31mfastai 0.7.0 has requirement torch<0.4, but you'll have torch 0.4.1 which is incompatible.\u001b[0m\n",
      "\u001b[33mYou are using pip version 10.0.1, however version 19.0.3 is available.\n",
      "You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "!pip install -q tensorflow_datasets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Dl Completed...: 0 url [00:00, ? url/s]\n",
      "Dl Completed...:   0%|          | 0/1 [00:00<?, ? url/s]\n",
      "Dl Size...: 0 MiB [00:00, ? MiB/s]\u001b[A"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[1mDownloading / extracting dataset imdb_reviews (80.23 MiB) to /home/czy/tensorflow_datasets/imdb_reviews/subwords8k/0.0.1...\u001b[0m\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Dl Completed...:   0%|          | 0/1 [00:00<?, ? url/s]\n",
      "Dl Size...:   0%|          | 0/80 [00:00<?, ? MiB/s]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [03:43<?, ? url/s]s/ MiB]\u001b[A\n",
      "Dl Size...:   1%|▏         | 1/80 [03:43<4:53:59, 223.29s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [08:38<?, ? url/s]s/ MiB]\u001b[A\n",
      "Dl Size...:   2%|▎         | 2/80 [08:38<5:18:23, 244.91s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [11:24<?, ? url/s]s/ MiB]\u001b[A\n",
      "Dl Size...:   4%|▍         | 3/80 [11:24<4:44:00, 221.30s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [14:25<?, ? url/s]s/ MiB]\u001b[A\n",
      "Dl Size...:   5%|▌         | 4/80 [14:25<4:24:41, 208.97s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [18:03<?, ? url/s]s/ MiB]\u001b[A\n",
      "Dl Size...:   6%|▋         | 5/80 [18:03<4:24:36, 211.68s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [23:14<?, ? url/s]s/ MiB]\u001b[A\n",
      "Dl Size...:   8%|▊         | 6/80 [23:14<4:58:04, 241.68s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [26:29<?, ? url/s]s/ MiB]\u001b[A\n",
      "Dl Size...:   9%|▉         | 7/80 [26:29<4:36:47, 227.50s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [30:10<?, ? url/s]s/ MiB]\u001b[A\n",
      "Dl Size...:  10%|█         | 8/80 [30:10<4:30:53, 225.74s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [33:29<?, ? url/s]s/ MiB]\u001b[A\n",
      "Dl Size...:  11%|█▏        | 9/80 [33:29<4:17:32, 217.63s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [35:57<?, ? url/s]0s/ MiB]\u001b[A\n",
      "Dl Size...:  12%|█▎        | 10/80 [35:57<3:49:29, 196.70s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [39:41<?, ? url/s]2s/ MiB]\u001b[A\n",
      "Dl Size...:  14%|█▍        | 11/80 [39:41<3:55:32, 204.82s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [42:57<?, ? url/s]7s/ MiB]\u001b[A\n",
      "Dl Size...:  15%|█▌        | 12/80 [42:57<3:49:07, 202.17s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [46:59<?, ? url/s]5s/ MiB]\u001b[A\n",
      "Dl Size...:  16%|█▋        | 13/80 [46:59<3:59:14, 214.25s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [49:38<?, ? url/s]8s/ MiB]\u001b[A\n",
      "Dl Size...:  18%|█▊        | 14/80 [49:38<3:37:20, 197.58s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [51:41<?, ? url/s]0s/ MiB]\u001b[A\n",
      "Dl Size...:  19%|█▉        | 15/80 [51:41<3:09:48, 175.20s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [54:08<?, ? url/s]6s/ MiB]\u001b[A\n",
      "Dl Size...:  20%|██        | 16/80 [54:08<2:57:58, 166.86s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [56:16<?, ? url/s]5s/ MiB]\u001b[A\n",
      "Dl Size...:  21%|██▏       | 17/80 [56:16<2:42:47, 155.05s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [58:45<?, ? url/s]1s/ MiB]\u001b[A\n",
      "Dl Size...:  22%|██▎       | 18/80 [58:45<2:38:24, 153.31s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:00:49<?, ? url/s]1s/ MiB]\u001b[A\n",
      "Dl Size...:  24%|██▍       | 19/80 [1:00:49<2:26:48, 144.41s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:03:10<?, ? url/s]7s/ MiB]\u001b[A\n",
      "Dl Size...:  25%|██▌       | 20/80 [1:03:10<2:23:28, 143.47s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:05:50<?, ? url/s]3s/ MiB]\u001b[A\n",
      "Dl Size...:  26%|██▋       | 21/80 [1:05:50<2:26:08, 148.63s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:07:59<?, ? url/s]6s/ MiB]\u001b[A\n",
      "Dl Size...:  28%|██▊       | 22/80 [1:07:59<2:17:48, 142.56s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:10:17<?, ? url/s]8s/ MiB]\u001b[A\n",
      "Dl Size...:  29%|██▉       | 23/80 [1:10:17<2:14:12, 141.28s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:12:20<?, ? url/s]9s/ MiB]\u001b[A\n",
      "Dl Size...:  30%|███       | 24/80 [1:12:20<2:06:49, 135.89s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:13:10<?, ? url/s]4s/ MiB]\u001b[A\n",
      "Dl Size...:  31%|███▏      | 25/80 [1:13:10<1:40:41, 109.84s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:14:29<?, ? url/s]3s/ MiB]\u001b[A\n",
      "Dl Size...:  32%|███▎      | 26/80 [1:14:29<1:30:45, 100.83s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:16:32<?, ? url/s]7s/ MiB]\u001b[A\n",
      "Dl Size...:  34%|███▍      | 27/80 [1:16:32<1:34:50, 107.37s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:18:52<?, ? url/s]5s/ MiB]\u001b[A\n",
      "Dl Size...:  35%|███▌      | 28/80 [1:18:52<1:41:37, 117.25s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:20:56<?, ? url/s]0s/ MiB]\u001b[A\n",
      "Dl Size...:  36%|███▋      | 29/80 [1:20:56<1:41:24, 119.30s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:22:52<?, ? url/s]9s/ MiB]\u001b[A\n",
      "Dl Size...:  38%|███▊      | 30/80 [1:22:52<1:38:29, 118.19s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:24:47<?, ? url/s]1s/ MiB]\u001b[A\n",
      "Dl Size...:  39%|███▉      | 31/80 [1:24:47<1:35:38, 117.11s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:26:45<?, ? url/s]8s/ MiB]\u001b[A\n",
      "Dl Size...:  40%|████      | 32/80 [1:26:45<1:33:59, 117.48s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:28:37<?, ? url/s]7s/ MiB]\u001b[A\n",
      "Dl Size...:  41%|████▏     | 33/80 [1:28:37<1:30:50, 115.97s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:29:07<?, ? url/s]s/ MiB] \u001b[A\n",
      "Dl Size...:  42%|████▎     | 34/80 [1:29:07<1:08:59, 90.00s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:29:31<?, ? url/s] MiB]  \u001b[A\n",
      "Dl Size...:  44%|████▍     | 35/80 [1:29:31<52:46, 70.37s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:30:08<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  45%|████▌     | 36/80 [1:30:08<44:10, 60.24s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:31:11<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  46%|████▋     | 37/80 [1:31:11<43:48, 61.13s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:33:11<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  48%|████▊     | 38/80 [1:33:11<55:12, 78.87s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:34:59<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  49%|████▉     | 39/80 [1:34:59<59:46, 87.48s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:36:33<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  50%|█████     | 40/80 [1:36:33<59:37, 89.44s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:36:54<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  51%|█████▏    | 41/80 [1:36:54<44:42, 68.78s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:37:24<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  52%|█████▎    | 42/80 [1:37:24<36:17, 57.31s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:38:26<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  54%|█████▍    | 43/80 [1:38:26<36:15, 58.81s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:39:44<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  55%|█████▌    | 44/80 [1:39:44<38:40, 64.45s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:40:09<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  56%|█████▋    | 45/80 [1:40:09<30:45, 52.74s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:40:40<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  57%|█████▊    | 46/80 [1:40:40<26:10, 46.19s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:41:59<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  59%|█████▉    | 47/80 [1:41:59<30:41, 55.79s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:43:43<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  60%|██████    | 48/80 [1:43:43<37:29, 70.31s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:45:30<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  61%|██████▏   | 49/80 [1:45:30<41:59, 81.28s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:47:04<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  62%|██████▎   | 50/80 [1:47:04<42:39, 85.30s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:48:48<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  64%|██████▍   | 51/80 [1:48:48<43:51, 90.75s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:50:26<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  65%|██████▌   | 52/80 [1:50:26<43:27, 93.13s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:51:54<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  66%|██████▋   | 53/80 [1:51:54<41:12, 91.57s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:53:24<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  68%|██████▊   | 54/80 [1:53:24<39:29, 91.15s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:55:03<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  69%|██████▉   | 55/80 [1:55:03<38:54, 93.40s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:56:28<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  70%|███████   | 56/80 [1:56:28<36:19, 90.79s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:57:50<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  71%|███████▏  | 57/80 [1:57:50<33:47, 88.17s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [1:59:22<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  72%|███████▎  | 58/80 [1:59:22<32:45, 89.33s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:00:33<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  74%|███████▍  | 59/80 [2:00:33<29:19, 83.80s/ MiB]\u001b[A\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Dl Completed...:   0%|          | 0/1 [2:02:00<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  75%|███████▌  | 60/80 [2:02:00<28:14, 84.70s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:03:27<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  76%|███████▋  | 61/80 [2:03:27<27:05, 85.57s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:04:46<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  78%|███████▊  | 62/80 [2:04:46<25:02, 83.47s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:06:04<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  79%|███████▉  | 63/80 [2:06:04<23:10, 81.77s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:07:18<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  80%|████████  | 64/80 [2:07:18<21:13, 79.59s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:08:38<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  81%|████████▏ | 65/80 [2:08:38<19:55, 79.72s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:09:48<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  82%|████████▎ | 66/80 [2:09:48<17:53, 76.69s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:11:01<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  84%|████████▍ | 67/80 [2:11:01<16:23, 75.68s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:12:22<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  85%|████████▌ | 68/80 [2:12:22<15:27, 77.27s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:13:29<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  86%|████████▋ | 69/80 [2:13:29<13:35, 74.14s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:14:49<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  88%|████████▊ | 70/80 [2:14:49<12:39, 75.98s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:16:02<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  89%|████████▉ | 71/80 [2:16:02<11:16, 75.15s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:17:15<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  90%|█████████ | 72/80 [2:17:15<09:55, 74.47s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:18:18<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  91%|█████████▏| 73/80 [2:18:18<08:17, 71.08s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:19:18<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  92%|█████████▎| 74/80 [2:19:18<06:44, 67.47s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:20:22<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  94%|█████████▍| 75/80 [2:20:22<05:32, 66.58s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:21:14<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  95%|█████████▌| 76/80 [2:21:14<04:09, 62.33s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:21:57<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  96%|█████████▋| 77/80 [2:21:57<02:48, 56.31s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:22:48<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  98%|█████████▊| 78/80 [2:22:48<01:49, 54.91s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:23:34<?, ? url/s] MiB]\u001b[A\n",
      "Dl Size...:  99%|█████████▉| 79/80 [2:23:34<00:52, 52.22s/ MiB]\u001b[A\n",
      "Dl Completed...:   0%|          | 0/1 [2:24:27<?, ? url/s] MiB]\u001b[A\n",
      "Dl Completed...: 100%|██████████| 1/1 [2:24:37<00:00, 8677.36s/ url]\n",
      "Dl Size...: 100%|██████████| 80/80 [2:24:37<00:00, 52.36s/ MiB]\u001b[A\n",
      "0 examples [00:00, ? examples/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "25000 examples [00:25, 975.34 examples/s] \n",
      "Shuffling...:   0%|          | 0/10 [00:00<?, ? shard/s]WARNING: Logging before flag parsing goes to stderr.\n",
      "W0408 01:56:15.224409 140157398619904 deprecation.py:323] From /home/czy/anaconda3/envs/tf2_0/lib/python3.6/site-packages/tensorflow_datasets/core/file_format_adapter.py:249: tf_record_iterator (from tensorflow.python.lib.io.tf_record) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Use eager execution and: \n",
      "`tf.data.TFRecordDataset(path)`\n",
      "\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 60539.24 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Writing...: 100%|██████████| 2500/2500 [00:00<00:00, 93611.99 examples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 180642.58 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Shuffling...:  20%|██        | 2/10 [00:00<00:00, 18.33 shard/s]xamples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 263434.83 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Writing...: 100%|██████████| 2500/2500 [00:00<00:00, 210781.76 examples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 223849.03 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Shuffling...:  40%|████      | 4/10 [00:00<00:00, 18.54 shard/s]xamples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 202580.32 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Writing...: 100%|██████████| 2500/2500 [00:00<00:00, 226503.65 examples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 271722.21 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Writing...: 100%|██████████| 2500/2500 [00:00<00:00, 212073.46 examples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 270432.76 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Writing...: 100%|██████████| 2500/2500 [00:00<00:00, 235931.96 examples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 261054.10 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Shuffling...:  80%|████████  | 8/10 [00:00<00:00, 21.68 shard/s]xamples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 287975.39 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Writing...: 100%|██████████| 2500/2500 [00:00<00:00, 249085.68 examples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 245562.40 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Shuffling...: 100%|██████████| 10/10 [00:00<00:00, 23.54 shard/s]amples/s]\u001b[A\n",
      "25000 examples [00:24, 1001.67 examples/s]\n",
      "Shuffling...:   0%|          | 0/10 [00:00<?, ? shard/s]\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 262932.80 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Writing...: 100%|██████████| 2500/2500 [00:00<00:00, 230517.06 examples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 256544.91 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Writing...: 100%|██████████| 2500/2500 [00:00<00:00, 225986.21 examples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 283284.07 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Writing...: 100%|██████████| 2500/2500 [00:00<00:00, 229860.14 examples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 310541.97 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Shuffling...:  40%|████      | 4/10 [00:00<00:00, 38.92 shard/s]xamples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 288879.83 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Writing...: 100%|██████████| 2500/2500 [00:00<00:00, 223954.21 examples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 330603.78 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Writing...: 100%|██████████| 2500/2500 [00:00<00:00, 248666.29 examples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 298594.98 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Writing...: 100%|██████████| 2500/2500 [00:00<00:00, 240581.85 examples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 320665.44 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Writing...: 100%|██████████| 2500/2500 [00:00<00:00, 246822.49 examples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 235650.94 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Shuffling...:  90%|█████████ | 9/10 [00:00<00:00, 39.48 shard/s]xamples/s]\u001b[A\n",
      "Reading...: 0 examples [00:00, ? examples/s]\u001b[A\n",
      "Reading...: 2500 examples [00:00, 230466.39 examples/s]\u001b[A\n",
      "Writing...:   0%|          | 0/2500 [00:00<?, ? examples/s]\u001b[A\n",
      "Shuffling...: 100%|██████████| 10/10 [00:00<00:00, 36.26 shard/s]amples/s]\u001b[A\n"
     ]
    }
   ],
   "source": [
    "import tensorflow_datasets as tfds\n",
    "dataset, info = tfds.load('imdb_reviews/subwords8k', with_info=True,\n",
    "                         as_supervised=True) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
